package com.frejoys.service;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.frejoys.common.dto.admin.AuthRuleAccessDeleteDto;
import com.frejoys.common.dto.admin.UserNameAndPhoneDto;
import com.frejoys.common.dto.common.auth.AuthGroupAccessListDto;
import com.frejoys.common.vo.admin.AuthRuleAccessListVo;
import com.frejoys.dao.entity.AuthGroupAccess;

import java.util.List;

public interface AuthGroupAccessService extends IService<AuthGroupAccess> {

    default AuthGroupAccess getOnly(QueryWrapper<AuthGroupAccess> wrapper) {
        wrapper.last("limit 1");
        return this.getOne(wrapper);
    }

    default AuthGroupAccess getOnly(LambdaQueryWrapper<AuthGroupAccess> wrapper) {
        wrapper.last("limit 1");
        return this.getOne(wrapper);
    }

    /**
     * 创建
     * @param userId
     * @param groupId
     * @return
     */
    Boolean addInfo(Long userId, Integer groupId);

    /**
     * 删除
     * @param userId
     * @param groupId
     * @param type
     * @return
     */
    Boolean deleteByUserId(Long userId);

    /**
     * 判断是否是超级管理员权限，权限组id=1为超级管理员
     * @param userId
     * @return
     */
    Boolean isSuperAdmin(Long userId);

    /**
     * 列表
     * @param userId
     * @param dto
     * @return
     */
    List<AuthGroupAccess> getList(Long userId, AuthGroupAccessListDto dto);

    /**
     * 获取用户权限关联
     * @param userId
     * @return
     */
    List<AuthGroupAccess> getListByUserId(Long userId);

    /**
     * 获取用户权限关联
     * @param groupId
     * @return
     */
    List<AuthGroupAccess> getListByGroupId(Long groupId);

    IPage<AuthRuleAccessListVo> authRuleAccessList(UserNameAndPhoneDto dto);

    //更换用户权限
    boolean authRuleAccessUpInfo(AuthRuleAccessDeleteDto dto);
}
